﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ling
{
    public partial class ling
    {
        public ling()
        {
            InitializeComponent();
        }

        public void Mysort(int[] arr)         //排序
        {
            var integers =
                from n in arr
                orderby n descending
                select n;
            int[] MysortArr = integers.ToArray();
            for (int i = 0; i < MysortArr.Length; i++)
            {
                sort.Text += (MysortArr[i].ToString() + "  ");
                if (i % 10 == 0)
                {
                    sort.Text += "\r\n";
                }
            }
        }

        public void Myrun(int[] arr)
        {
            int total = arr.Sum();
            double eves = arr.Average();
            sum.Text = total.ToString();
            ave.Text = eves.ToString();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Random random = new Random();
            int[] vs = new int[100];
            for (int i = 0; i < vs.Length; i++)
            {
                vs[i] = random.Next(1000);//随机生成0到1000之间的整数，不含1000
                for(int j = 0; j <= 1000; i++)
                {
                    int m = vs[j];
                    integer.Text += m.ToString();
                }
            }
            Myrun(vs);
            Mysort(vs);
        }
    }
}
